<?php
class ClearTaskModule extends BaseModel
{
    private $_table_defaultproperty_clear_task  = "defaultproperty_clear_task";
    private $_table_defaultproperty_clear_record  = "defaultproperty_clear_record";


    public function __construct($db_choose = "default"){
        parent::__construct($db_choose);
    }

    /**
     * 资产清理任务
     * ******** start ********
     */
    public function getClearTaskList($where = array(),$field='*',$order='id desc',$offset = 0,$limit = 10) {
        $list = $this->table($this->_table_defaultproperty_clear_task)->field($field)->where($where)->order($order)->limit($offset,$limit)->select();
        if (empty($list)) {
            $list = array();
        }
        return $list;
    }
    public function getClearTaskCount($where = array()) {
        $count = $this->table($this->_table_defaultproperty_clear_task)->where($where)->count();
        return $count;
    }
    public function getClearTaskById($id){
        $where = array('id' => $id);
        return $this->table($this->_table_defaultproperty_clear_task)->where($where)->find();
    }
    public function addClearTask($data) {
        return $this->table($this->_table_defaultproperty_clear_task)->add($data);
    }
    public function saveClearTask($id,$data) {
        if (empty($id)){
            return false;
        }
        $where['id'] = $id;
        return $this->table($this->_table_defaultproperty_clear_task)->where($where)->save($data);
    }

    /**
     * 资产清理记录
     * ******** start ********
     */
    public function getClearRecordList($where = array(),$field='*',$order='id desc',$offset = 0,$limit = 10) {
        $list = $this->table($this->_table_defaultproperty_clear_record)->field($field)->where($where)->order($order)->limit($offset,$limit)->select();
        if (empty($list)) {
            $list = array();
        }
        return $list;
    }
    public function getClearRecordCount($where = array()) {
        $count = $this->table($this->_table_defaultproperty_clear_record)->where($where)->count();
        return $count;
    }
    public function getClearRecordById($id){
        $where = array('id' => $id);
        return $this->table($this->_table_defaultproperty_clear_record)->where($where)->find();
    }
    public function addClearRecord($data) {
        return $this->table($this->_table_defaultproperty_clear_record)->add($data);
    }
    public function saveClearRecord($id,$data) {
        if (empty($id)){
            return false;
        }
        $where['id'] = $id;
        return $this->table($this->_table_defaultproperty_clear_record)->where($where)->save($data);
    }
}
